/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vamprest;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author sav
 */
@Entity
@Table(name = "address")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Address.findAll", query = "SELECT a FROM Address a"),
    @NamedQuery(name = "Address.findByIddadress", query = "SELECT a FROM Address a WHERE a.iddadress = :iddadress"),
    @NamedQuery(name = "Address.findByIdgpslocation", query = "SELECT a FROM Address a WHERE a.idgpslocation = :idgpslocation")})
public class Address implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "iddadress")
    private Integer iddadress;
    @Basic(optional = false)
    @NotNull
    @Lob
    @Size(min = 1, max = 65535)
    @Column(name = "line1")
    private String line1;
    @Lob
    @Size(max = 65535)
    @Column(name = "line2")
    private String line2;
    @Lob
    @Size(max = 65535)
    @Column(name = "line3")
    private String line3;
    @Basic(optional = false)
    @NotNull
    @Lob
    @Size(min = 1, max = 65535)
    @Column(name = "zipcode")
    private String zipcode;
    @Basic(optional = false)
    @NotNull
    @Lob
    @Size(min = 1, max = 65535)
    @Column(name = "city")
    private String city;
    @Basic(optional = false)
    @NotNull
    @Lob
    @Size(min = 1, max = 65535)
    @Column(name = "country")
    private String country;
    @JoinColumn(name = "idgpslocation", referencedColumnName = "idgpslocation")
    @OneToOne(optional = true)
    private Gpslocation idgpslocation;
    @OneToMany(mappedBy = "idaddress")
    private Collection<Poi> poiCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idadress")
    private Collection<Route> routeCollection;

    public Address() {
    }

    public Address(Integer iddadress) {
        this.iddadress = iddadress;
    }

    public Address(Integer iddadress, String line1, String zipcode, String city, String country) {
        this.iddadress = iddadress;
        this.line1 = line1;
        this.zipcode = zipcode;
        this.city = city;
        this.country = country;
    }

    public Integer getIddadress() {
        return iddadress;
    }

    public void setIddadress(Integer iddadress) {
        this.iddadress = iddadress;
    }

    public String getLine1() {
        return line1;
    }

    public void setLine1(String line1) {
        this.line1 = line1;
    }

    public String getLine2() {
        return line2;
    }

    public void setLine2(String line2) {
        this.line2 = line2;
    }

    public String getLine3() {
        return line3;
    }

    public void setLine3(String line3) {
        this.line3 = line3;
    }

    public String getZipcode() {
        return zipcode;
    }

    public void setZipcode(String zipcode) {
        this.zipcode = zipcode;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    public Gpslocation getIdgpslocation() {
        return idgpslocation;
    }

    public void setIdgpslocation(Gpslocation idgpslocation) {
        this.idgpslocation = idgpslocation;
    }

    @XmlTransient
    public Collection<Poi> getPoiCollection() {
        return poiCollection;
    }

    public void setPoiCollection(Collection<Poi> poiCollection) {
        this.poiCollection = poiCollection;
    }

    @XmlTransient
    public Collection<Route> getRouteCollection() {
        return routeCollection;
    }

    public void setRouteCollection(Collection<Route> routeCollection) {
        this.routeCollection = routeCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (iddadress != null ? iddadress.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Address)) {
            return false;
        }
        Address other = (Address) object;
        if ((this.iddadress == null && other.iddadress != null) || (this.iddadress != null && !this.iddadress.equals(other.iddadress))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "vamprest.Address[ iddadress=" + iddadress + " ]";
    }

}
